<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维修店档案列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>店铺名称：</label>
                            <input id="storePerson" type="text" name="storeName"/>
                        </li>
                        <li>
                            <label>详细地址：</label>
                            <input id="storeAddress" type="text" name="storeAddress"/>
                        </li>
                        <li>
                            <label>联系方式：</label>
                            <input id="storePhone" type="text" name="storePhone"/>
                        </li>
                        <li>
                            <label>所属大区：</label>
                            <input id="agentName" type="text" name="agentName"/>
                        </li>
                        <li>
                            <label style="width: 160px;">审核状态：</label>
                            <select name="storeState" th:with="type=${@dict.getType('store_state')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <!--<li>
                            <label>接单区域：</label>
                            <input id="orderAddress" type="text" name="orderAddress"/>
                        </li>-->
                        <!--<li>
                            <label style="width: 140px;">是否订单提成人：</label>
                            <select name="isRaker" th:with="type=${@dict.getType('zsyh_yesno')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 140px;">是否拥有鉴定权：</label>
                            <select name="isAppraisal" th:with="type=${@dict.getType('zsyh_yesno')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                            </select>
                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('formId','bootstrap-table')"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-bordered">
            <table id="bootstrap-table"></table>
        </div>
    </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:repairStore:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:repairStore:remove')}]];
        var isRakerDatas = [[${@dict.getType('store_state')}]];
        var isAppraisalDatas = [[${@dict.getType('zsyh_yesno')}]];
        var prefix = ctx + "zsyh/repairStore";

        $(function() {
            var options = {
                id: "bootstrap-table",
                url: prefix + "/list?isRaker=1",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/removeNetwork",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                pageSize:10,
                modalName: "维修师傅档案",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '主键',
                    align: 'center',
                    visible: false
                },
                    {
                        field: 'storeName',
                        align: 'center',
                        title: '店铺名称'
                    },
                {
                    field: 'storeImage',
                    align: 'center',
                    title: '店铺门头',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                    {
                        field: 'storePerson',
                        align: 'center',
                        title: '负责人'
                    },
                    {
                        field: 'storePhone',
                        align: 'center',
                        title: '联系电话'
                    },
                    {
                        field: 'storeBusinessHours',
                        align: 'center',
                        title: '营业时间'
                    },{
                        field: 'storeOpenYears',
                        align: 'center',
                        title: '开业年限'
                    },
                /*{
                    field: 'storePageviews',
                    align: 'center',
                    title: '客户浏览量'
                },
                    {
                        field: 'orderAddress',
                        align: 'center',
                        title: '接单区域'
                    },*/
                {
                        field: 'agentName',
                        align: 'center',
                        title: '所属大区'
                    },
                    {
                        field: 'storeAddress',
                        align: 'center',
                        title: '详细地址'
                    },
                    {
                        field: 'storeState',
                        align: 'center',
                        title: '申请状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isRakerDatas, value);
                        }
                    },
                    {
                        field: 'createTime',
                        align: 'center',
                        title: '加入时间'
                    },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '"  style="margin: 0 3px;" href="javascript:void(0)" onclick="viewRepairStore(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        actions.push('<a class="btn btn-warning btn-xs" style="margin: 0 3px;" href="javascript:void(0)" onclick="updateRakerArea(\'' + row.id + '\')"><i class="fa fa-search"></i>调整管辖区域</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" style="margin: 0 3px;" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        if(row.storeState == "1"){
                            actions.push('<a style="margin-left: 3px;background-color: white;border-color: orangered;color: orangered;font-weight: bolder" class="btn btn-info btn-xs \' + removeFlag + \'" href="javascript:void(0)" onclick="checkStore(\'' + row.id + '\')"><i class="fa fa-check"></i>去审核</a> ');
                        }
                        if(row.storeState == "2" && row.agentName == null){
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="lockAgent(\'' + row.id + '\')"><i class="fa fa-lock"></i>归属大区会长</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function lockAgent(id) {
            var url = ctx + "zsyh/repairStore/lockAgent/" + id;
            $.modal.open("归属大区会长", url);
        }

        function lockAfter() {
            var $tableFlows = $('#bootstrap-table');
            var pg = $tableFlows.bootstrapTable('getOptions').pageNumber;  //获取当前页码
            // 跳转到对应的页面
            $tableFlows.bootstrapTable('selectPage', parseInt(pg));
        }


        function viewRepairStore(id) {
            var url = ctx+"zsyh/repairStore/viewNetworkStore/"+id;
            layer.open({
                type: 2,
                area: ['1200px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看详情",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function viewStoreCategory(id) {
            var url = ctx+"zsyh/storeCategory/viewStoreCategory?storeId="+id;
            layer.open({
                type: 2,
                area: ['1200px', ($(window).height()-50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看服务类目",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function closePartsCheck(id) {
            $.modal.confirm("确认要强制关闭该店铺鉴定权吗？", function() {
                $.operate.post(prefix + "/closePartsCheck", { "id":id,"type":"1"});
            })
        }

        function openPartsCheck(id) {
            $.modal.confirm("确认要打开该店铺鉴定权吗？", function() {
                $.operate.post(prefix + "/closePartsCheck", { "id":id,"type":"2"});
            })
        }

        function updateStore(id) {
            var url = ctx+"zsyh/repairStore/updateStore/"+id;
            layer.open({
                type: 2,
                area: ['500px', '300px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "更改店铺类型",
                content:  url,
                /*closeBtn: 1,*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(){
                    $.modal.alertWarning("更改完成");
                    var $tableFlows = $('#bootstrap-table');
                    var pg = $tableFlows.bootstrapTable('getOptions').pageNumber;  //获取当前页码
                    // 跳转到对应的页面
                    $tableFlows.bootstrapTable('selectPage', parseInt(pg));
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function checkStore(id) {
            var url = ctx+"zsyh/repairStore/checkStore/"+id;
            layer.open({
                type: 2,
                area: ['1200px', '800px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "审核店铺",
                content:  url,
                /*closeBtn: 1,*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(){
                    $.modal.alertWarning("审核完成");
                    var $tableFlows = $('#bootstrap-table');
                    var pg = $tableFlows.bootstrapTable('getOptions').pageNumber;  //获取当前页码
                    // 跳转到对应的页面
                    $tableFlows.bootstrapTable('selectPage', parseInt(pg));
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }


        function viewCheckParts(id) {
            var url = ctx+"zsyh/partsCheck/viewPartsCheck?storeId="+id;
            layer.open({
                type: 2,
                area: ['1200px', ($(window).height()-50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看鉴定权产品",
                content:  url,
                closeBtn: 1,
                // 弹层外区域关闭
                shadeClose: true,
                end: function(){
                    //location.reload();
                },
                cancel: function(index) {
                    //location.reload();
                }
            });
        }

        function updateRakerArea(id) {
            var url = prefix + '/updateRakerArea/'+id;
            layer.open({
                type: 2,
                area: [($(window).width()/2) + 'px', ($(window).height() - 50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看管辖区域",
                content: url,
                closeBtn: 1,
                /* btn: ['确定', '关闭'],*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    debugger;
                    var iframeWin = layero.find('iframe')[0];
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

    </script>
</body>
</html>